<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理系统</title>
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/css/common.css">
    <script src="/static/admin/js/jquery-3.0.0.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    {include file="common/top"}
    {include file="common/left"}
</div>
<div class="main-container">
    <!-- 面包屑 -->
    <!-- lay-separator="-" -->
    <span class="layui-breadcrumb" lay-separator="-">
            <a href="/admin/index/index">首页</a>
            <a href="/admin/goods/lst">商品列表</a>
            <a href="###">编辑商品</a>
        </span>
    <form class="layui-form" style="margin: 25px 0 0 0" method="post" action="edit" enctype="multipart/form-data"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        <input type="hidden" value="{$goods.id}" name="id">
        <div class="layui-tab layui-tab-brief">
            <!-- lay-allowClose="true" -->
            <ul class="layui-tab-title">
                <li>基本信息</li>
                <li>商品属性</li>


            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">选择分类</label>
                        <div class="layui-input-inline">
                            <select name="cate_id" lay-verify="required">
                                <option value="">请选择</option>
                                {volist name="cate" id="c"}
                                <option {if condition="$c.pid eq 0"}disabled{/if} value="{$c.id}" {if $c.id==$goods.cate_id}selected="selected"{/if}>{$c.level|rep_str} {$c.cate_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品名称</label>
                        <div class="layui-input-inline">
                            <input type="text" value="{$goods.goods_name}" name="goods_name" required  lay-verify="required" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">市场价</label>
                        <div class="layui-input-inline">
                            <input type="text" value="{$goods.market_price}" name="market_price" required  lay-verify="required" placeholder="请输入市场价格" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">销售价</label>
                        <div class="layui-input-inline">
                            <input type="text" value="{$goods.sale_price}" name="sale_price" required  lay-verify="required" placeholder="请输入销售价格" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">库存量</label>
                        <div class="layui-input-inline">
                            <input type="text" value="{$goods.reserve}" name="reserve" required  lay-verify="required" placeholder="库存量" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否上架</label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="onshelf" {if $goods.onshelf==1}checked="checked"{/if} lay-skin="switch" lay-text="上架|下架">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-upload">
                            <label class="layui-form-label">缩略图</label>

                            <button  type="button" class="layui-btn layui-icon layui-icon-upload" id="test1" style="vertical-align: top">上传图片</button>
                            <img class="layui-upload-img" style="width: 92px;height: 92px;margin: 0 10px 10px 0" id="demo1" src="/static/admin/uploads/{$goods.thumb}">
                            <p id="demoText"></p>
                            <input type="hidden" value="{$goods.thumb}" name="thumb" id="thumb">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">商品描述</label>
                        <div class="layui-input-inline">
                            <textarea name="description" placeholder="请输入内容" class="layui-textarea">{$goods.description}</textarea>
                        </div>
                    </div>

                </div>

                <!--                属性-->
                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">厂家</label>
                        <div class="layui-input-inline">
                            <input type="text" name="manufactor" value="{$attrs.manufactor}"   placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">保质期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="qualityday"  value="{$attrs.qualityday}"   placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">净含量</label>
                        <div class="layui-input-inline">
                            <input type="text" name="weight"  value="{$attrs.weight}"   placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">单位</label>
                        <div class="layui-input-inline">
                            <input type="text" name="unit" value="{$attrs.unit}"   placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">口味</label>
                        <div class="layui-input-inline">
                            <input type="text" name="flavor" value="{$attrs.flavor}"    placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>





            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            </div>
        </div>
    </form>

</div>
</body>
<script src="/static/admin/layui/layui.js"></script>
<script>
    layui.use(['element','form'],() =>{
    });
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: 'uploads' //改成您自己的上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                console.log(res.code);
                if(res.code > 0){
                    return layer.msg('上传失败');
                }else{
                    //上传成功
                    var x=res.date+'/'+res.url;
                    $('#thumb').val(x);
                    console.log(res);
                }

            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });



    });




</script>
<!-- <script src="../layui/layui.all.js"></script>
<script>
    window.onload = () => {
        layui.layer.msg('Hello Layui!');
    }
</script> -->
</html>